from datetime import datetime
from os import getenv

from flask import Response, render_template

from . import app
from .models.user import User


@app.route("/")
def home() -> str:
    return render_template("home.html")


@app.route("/about")
def about() -> str:
    return render_template("about.html", flask_env=getenv("FLASK_ENV"))


@app.route("/contact")
def contact() -> str:
    users = User.query.all()
    return render_template("contact.html", users=users)


@app.route("/hello/")
@app.route("/hello/<name>")
def hello_there(name: str = None) -> str:
    return render_template("hello_there.html", name=name, time_now=datetime.now())


@app.route("/api/data")
def get_data() -> Response:
    return app.send_static_file("data.json")
